<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>

<div id="left">
<h2>收藏此文章:</h2>
<h3>${article.title}</h3>
<form id="form1" name="form1" method="post" action="saveArticle.html" 
	onSubmit="former.ajaxSubmitForm();return false;">
<table class="detail">
	<spring:bind path="article.articleId">
		<input type="hidden" name="id" value="${status.value}" />
	</spring:bind>

	<tr>
		<td>标签：</td>
		<td><input type="text" id="tagStr" name="tagStr" value="" size=20 /></td>
	</tr>

	<tr>
		<td align=center><input type="submit" class="button" name="save"
			value="收藏"/> <input
			type="button" class="button" name="cancel" value="返回"
			onclick="javascript:TB_remove();" /></td>
	</tr>

</table>
推荐tag:<c:forEach items="${article.tagSet}" var="tag">
	<a href="javascript:clickTag('${tag.title}')">${tag.title}</a>&nbsp;
<c:set var="tagStr" value="" />
</c:forEach> <br>
您的tag<a href="javascript:refreshTag()">>></a>
<div id="tags"></div>
</form>
</div>
<script type='text/javascript' LANGUAGE="javascript">
var former = new AjaxFormer($$('form1'));
var init=false;
   function clickTag(tag){
         var s= $$("tagStr").value;
         var i=s.indexOf(tag);
         if(i>=0){
         	 $$("tagStr").value=s.substring(0,i)+s.substring(i+s.length+1,s.length);
			
        }else{
        	$$("tagStr").value=s+" "+tag;

        	}
   }
  
    function refreshTag()
    {
    if(!init){
		$("#tags").html("载入中...");
        $("#tags").load("listFansTag.ajax");
         init=true;
         $$("tags").style.display="inline";
    }else{
    	 if($$("tags").style.display=="inline") {
    	      $$("tags").style.display="none";
    	 }else{
    	      $$("tags").style.display="inline";
    	 }
     }
    }
	
	function ajaxValidate(){
	// var str=$("tagStr").value.trim();
    //	if(str==""){ 
    //	alert("请输入或选择标签"); 
    //	return false;
    //	}
    return true;
	}
	
	function ajaxSucess(){
	$$("saveStatus_${article.articleId}").innerHTML="您已收藏";
	$$("saveCount_${article.articleId}").innerHTML=1+parseInt($$("saveCount_${article.articleId}").innerHTML);
    addTag($$("tagStr").value.trim(),$$("articleTags_${article.articleId}").innerHTML);
    TB_remove();	     
	}

    function addTag(str,str2){
	var a=str.split(' ');
	for (i=0;i<a.length;i++)   {
		 if((a[i].trim()!='')&&(str2.indexOf(a[i])==-1)){
	     $$("articleTags_${article.articleId}").innerHTML+="<a class=tag href=viewTag.html?name="+a[i]+">"+a[i]+"</a>&nbsp;&nbsp;";
	   		}
		}
}    
</script>

<div id="right">
<div class="tips">提示：输入您认为的标签，<b>用空格分隔多个标签</b>，用空格分隔，就会将此文章收藏到您相应标签下<br>
小技巧：标签也就是Tag，是为了您方便的管理文章，并在社区内更方便的与他人分享。建议标签简洁常用，比如spring，hibernate，ajax等，避免使用较长的标签</div>
</div>

